package com.example.administrator.familfinalcialmanagement.greendao.gen;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.example.administrator.familfinalcialmanagement.bean.WalletBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "WALLET_BEAN".
*/
public class WalletBeanDao extends AbstractDao<WalletBean, Long> {

    public static final String TABLENAME = "WALLET_BEAN";

    /**
     * Properties of entity WalletBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property WalletName = new Property(1, String.class, "walletName", false, "WALLET_NAME");
        public final static Property WalletStyle = new Property(2, String.class, "walletStyle", false, "WALLET_STYLE");
        public final static Property Money = new Property(3, String.class, "money", false, "MONEY");
        public final static Property WalletOne = new Property(4, String.class, "walletOne", false, "WALLET_ONE");
        public final static Property WalletTwo = new Property(5, String.class, "walletTwo", false, "WALLET_TWO");
        public final static Property WalletThree = new Property(6, String.class, "walletThree", false, "WALLET_THREE");
        public final static Property WalletFour = new Property(7, String.class, "walletFour", false, "WALLET_FOUR");
    }


    public WalletBeanDao(DaoConfig config) {
        super(config);
    }
    
    public WalletBeanDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"WALLET_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
                "\"WALLET_NAME\" TEXT," + // 1: walletName
                "\"WALLET_STYLE\" TEXT," + // 2: walletStyle
                "\"MONEY\" TEXT," + // 3: money
                "\"WALLET_ONE\" TEXT," + // 4: walletOne
                "\"WALLET_TWO\" TEXT," + // 5: walletTwo
                "\"WALLET_THREE\" TEXT," + // 6: walletThree
                "\"WALLET_FOUR\" TEXT);"); // 7: walletFour
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"WALLET_BEAN\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, WalletBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String walletName = entity.getWalletName();
        if (walletName != null) {
            stmt.bindString(2, walletName);
        }
 
        String walletStyle = entity.getWalletStyle();
        if (walletStyle != null) {
            stmt.bindString(3, walletStyle);
        }
 
        String money = entity.getMoney();
        if (money != null) {
            stmt.bindString(4, money);
        }
 
        String walletOne = entity.getWalletOne();
        if (walletOne != null) {
            stmt.bindString(5, walletOne);
        }
 
        String walletTwo = entity.getWalletTwo();
        if (walletTwo != null) {
            stmt.bindString(6, walletTwo);
        }
 
        String walletThree = entity.getWalletThree();
        if (walletThree != null) {
            stmt.bindString(7, walletThree);
        }
 
        String walletFour = entity.getWalletFour();
        if (walletFour != null) {
            stmt.bindString(8, walletFour);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, WalletBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String walletName = entity.getWalletName();
        if (walletName != null) {
            stmt.bindString(2, walletName);
        }
 
        String walletStyle = entity.getWalletStyle();
        if (walletStyle != null) {
            stmt.bindString(3, walletStyle);
        }
 
        String money = entity.getMoney();
        if (money != null) {
            stmt.bindString(4, money);
        }
 
        String walletOne = entity.getWalletOne();
        if (walletOne != null) {
            stmt.bindString(5, walletOne);
        }
 
        String walletTwo = entity.getWalletTwo();
        if (walletTwo != null) {
            stmt.bindString(6, walletTwo);
        }
 
        String walletThree = entity.getWalletThree();
        if (walletThree != null) {
            stmt.bindString(7, walletThree);
        }
 
        String walletFour = entity.getWalletFour();
        if (walletFour != null) {
            stmt.bindString(8, walletFour);
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public WalletBean readEntity(Cursor cursor, int offset) {
        WalletBean entity = new WalletBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // walletName
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // walletStyle
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // money
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // walletOne
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // walletTwo
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // walletThree
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // walletFour
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, WalletBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setWalletName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setWalletStyle(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setMoney(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setWalletOne(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setWalletTwo(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setWalletThree(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setWalletFour(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(WalletBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(WalletBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(WalletBean entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
